//---------------------------------------------------------------------------





#ifndef CNetH
#define CNetH
//---------------------------------------------------------------------------

#include <IdUDPClient.hpp>
#include <IdUDPServer.hpp>
#include <IdTCPClient.hpp>
#include <IdTCPServer.hpp>



typedef struct
{
   TIdUDPServer *pServer;
   TIdUDPClient *pClient;
}UDP_Componet;

typedef struct
{
   TIdTCPServer *pServer;
   TIdTCPClient *pClient;
}TCP_Componet;

typedef struct
{
   UDP_Componet udp;
   TCP_Componet tcp;
}NetworkComponets;

class CNetworkBase
{
public:

   CNetworkBase()
   {
      fInitialized=false;

      fUDPServerOpen = false;
      fUDPClintOpen = false;
      fTCPServerOpen = false;
      fTCPClintOpen = false;

      fUDPClientEnabled = false;
      fUDPServerEnabled = false;
      fTCPClientEnabled = false;
      fTCPServerEnabled = false;

      m_pUdpBuffer=NULL;
   }
   ~CNetworkBase()
   {
      NetClose();
   }

   bool NetInit(NetworkComponets *nc);
   void NetClose();

   bool SetUDPAddr(char *szIpAddrSvr, int iPortSvr, char *szIpAddrClt, int iPortClt);
   bool OpenUDP();
   bool CloseUDP();
   BOOL SendUDPString(char *szStr);
   BOOL SendUDPData(void *pData, int iSize);
   bool OnRecieveUdp(void *pData, int iSize);

   bool SetTCPAddr(char *szIpAddrSvr, int iPortSvr, char *szIpAddrClt, int iPortClt);
   bool OpenTCP();
   bool CloseTCP();
   BOOL SendTCPString(char *szStr);
   BOOL SendTCPData(void *pData, int iSize);

   //bool Enable();
   //bool Disable();

private:
   bool fInitialized;
   bool fPortInit;
   bool fUDPServerOpen;
   bool fUDPClintOpen;
   bool fTCPServerOpen;
   bool fTCPClintOpen;

   bool fUDPClientEnabled;
   bool fUDPServerEnabled;
   bool fTCPClientEnabled;
   bool fTCPServerEnabled;


   NetworkComponets m_nc;


   byte *m_pUdpBuffer;

  /* char m_szIpAddrSvr[25];
   char m_szIpAddrClt[25];

   int m_iPortSvr;
   int m_iPortClt;
    */
  /*
   BOOL EnableServer();
   BOOL EnableClient();
   BOOL DisableServer();
   BOOL DisableClient();

   bool SetAddrUDP_Server();
   bool SetAddrUDP_Client();

    */
   bool CloseConnections();

};



#endif
